#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <memory.h>
#include <string.h>

const int MAX_CHAR_INPUT = 200001;
const int BUCKET_SIZE = 256;
typedef unsigned char uchar;

static int SuffixArray( const uchar* buffer, int bufferLen, 
					    int* sa, int saLen,
						int* ia, int iaLen
					   )
{
	assert(buffer && bufferLen > 0);
	assert(sa && saLen == bufferLen);
	assert(ia && iaLen == BUCKET_SIZE);

	// clear suffix array
	for (int i = 0; i < saLen; ++i)
		sa[i] = 0;

	int bucket[BUCKET_SIZE];
	memset(bucket, 0, sizeof(bucket));
	int startIdx[BUCKET_SIZE];
	memset(startIdx, 0, sizeof(bucket));
	for (int i = 0; i < bufferLen; ++i)
		++bucket[buffer[i]];

	int idx = 0;
	for (int i = 1; i < BUCKET_SIZE; ++i)
	{
		idx += bucket[i - 1];
		if (bucket[i])
			startIdx[i] = idx;
		else 
			startIdx[i] = 0;
	}

	for (int i = 0; i < BUCKET_SIZE; ++i)
	{
		ia[i] = startIdx[i];
	}

	for (int i = 0; i < bufferLen; ++i)
	{
		int j = startIdx[buffer[i]]++;
		sa[j] = i;
	}

	return 0;
}

static int SuffixArrayMatch(int* matchPos, int* matchLen, 
							const uchar* srcStr, int srcStrLen, 
							const uchar* dstStr, int dstStrLen,
							int* suffixArray, int suffixArrayLen,
							int* ia, int iaLen)
{
	assert(matchPos && matchLen);
	assert(srcStr && srcStrLen > 0 && srcStrLen <= strlen((const char*)srcStr));
	assert(dstStr && dstStrLen > 0 && dstStrLen <= strlen((const char*)dstStr));
	assert(suffixArray && suffixArrayLen == dstStrLen);
	assert(ia && iaLen == BUCKET_SIZE);

	int maxMatch = 0;
	int posMatch = 0;
	for (int i = 0; i < srcStrLen; ++i)
	{
		for (int saIdx = ia[srcStr[i]]; saIdx < suffixArrayLen && dstStr[suffixArray[saIdx]] == srcStr[i]; ++saIdx)
		{
			int numMatch = 0;
			for (int idxSrc = i, idxDst = suffixArray[saIdx]; srcStr[idxSrc] == dstStr[idxDst]; ++idxSrc, ++idxDst)
				++numMatch;

			if (numMatch > maxMatch)
			{
				maxMatch = numMatch;
				posMatch = i;
			}
		}
	}

	*matchPos = posMatch;
	*matchLen = maxMatch;

	return 0;
}

int main(int argc, const char** argv)
{
	char* s1 = new char[MAX_CHAR_INPUT];
	memset(s1, 0, MAX_CHAR_INPUT * sizeof(char));
	char* s2 = new char[MAX_CHAR_INPUT];
	memset(s2, 0, MAX_CHAR_INPUT * sizeof(char));
	int ia[BUCKET_SIZE];
	memset(ia, 0, sizeof(ia));

	scanf("%s%s", s1, s2);

	int s1Len = strlen(s1);
	int* s1SuffixArray = new int[s1Len];
	memset(s1SuffixArray, 0, s1Len * sizeof(int));
	
	int err = SuffixArray((const uchar*)s1, s1Len, 
						  s1SuffixArray, s1Len, 
						  ia, BUCKET_SIZE);
	assert(err == 0);
	int matchPos = 0;
	int matchLen = 0;
	err = SuffixArrayMatch(&matchPos, &matchLen, 
					 (const uchar*)s2, strlen(s2), 
					 (const uchar*)s1, strlen(s1),
					 s1SuffixArray, s1Len,
					 ia, sizeof(ia) / sizeof(int) );
	assert(err == 0);

	printf("%d\n", matchLen);

	delete []s1SuffixArray;
	s1SuffixArray = NULL;
	delete []s1;
	s1 = NULL;
	delete []s2;
	s2 = NULL;

	return 0;
}